//
//  MySQLException.m
//  LibMySQL
//
//  Created by Marcus Grenängen on 2009-07-16.
//  Copyright 2009 SneWs Soft. All rights reserved.
//
#import "MySQLException.h"

@interface MySQLException (Private)
@property (nonatomic, readwrite, retain) NSString *errorMessage;
@property (nonatomic, readwrite, assign) NSInteger errorNumber;
@property (nonatomic, readwrite, retain) NSString* sqlStatement;

- (id)initWithName:(NSString*)aName reason:(NSString*)txt userInfo:(NSDictionary*)uinfo mysqlError:(NSString*)myErr andMySQLErrorNumber:(NSInteger)myErrNo;
@end

@implementation MySQLException

#pragma mark -
#pragma mark Properties, GET / SET
@synthesize errorMessage;
@synthesize errorNumber;
@synthesize sqlStatement;

#pragma mark -
#pragma mark Initialization
- (id)init {
	return [self initWithName:@"" reason:@"" userInfo:nil mysqlError:@"" andMySQLErrorNumber:0];

} // END METHOD: init:

- (id)initWithName:(NSString *)aName reason:(NSString *)txt userInfo:(NSDictionary *)uinfo {
	return [self initWithName:aName reason:txt userInfo:uinfo mysqlError:@"" andMySQLErrorNumber:0];
} // END METHOD: initWithName:

- (id)initWithName:(NSString *)aName reason:(NSString *)txt mysqlError:(NSString *)myErr andMySQLErrorNumber:(NSInteger)myErrNo {
	return [self initWithName:aName reason:txt userInfo:nil mysqlError:myErr andMySQLErrorNumber:myErrNo];
} // END METHOD: initWithName:

- (id)initWithName:(NSString *)aName reason:(NSString *)txt userInfo:(NSDictionary *)uinfo mysqlError:(NSString *)myErr andMySQLErrorNumber:(NSInteger)myErrNo {
	if (self = [super initWithName: aName reason: txt userInfo: uinfo]) {
		errorMessage = [myErr retain];
		errorNumber = myErrNo;
	} // END if (self = [super initWithName: aName reason: txt userInfo: uinfo])
	
	return self;
} // END METHOD: initWithName:
  
- (void)dealloc {
	[errorMessage release];
	[sqlStatement release];
	
	[super dealloc];
	
} // END METHOD: dealloc:


- (NSString *)description {
	NSMutableString *retVal = [NSMutableString stringWithFormat: @"%@", [super description]];
	[retVal appendFormat: @"\nMySQL Error Nr. %i\nMySQL Error: %@",
							errorNumber, errorMessage];
	return retVal;

} // END METHOD: description: 










@end